package com.hucheng.activity.vo;

import com.hucheng.activity.entity.ExchangeDetailsDO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;

/**
 * @Author: 凉白开不加冰
 * @Version: 0.0.1V
 * @Date: 2019-07-15
 * @Description: 返回界面数据
 **/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ExchangeDetailsVO implements Serializable {
    private Integer exchangeDetailsId;
    private Integer userId;
    private Integer exchangeConfigId;
    private Integer exchangeNo;
    private String exchangeName;
    private String dateCreated;
    private String dateUpdated;
    private Integer isDel;

    public static ExchangeDetailsVO buildExchangeVO(final ExchangeDetailsDO exchangeDetailsDO) {
        if (exchangeDetailsDO == null) {
            return null;
        }
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return new ExchangeDetailsVO(
                exchangeDetailsDO.getExchangeDetailsId(),
                exchangeDetailsDO.getUserId(),
                exchangeDetailsDO.getExchangeConfigId(),
                exchangeDetailsDO.getExchangeNo(),
                exchangeDetailsDO.getExchangeName(),
                dateTimeFormatter.format(exchangeDetailsDO.getDateCreated().toLocalDateTime()),
                dateTimeFormatter.format(exchangeDetailsDO.getDateUpdated().toLocalDateTime()),
                exchangeDetailsDO.getIsDel());
    }
}
